package com.itheima.heima.info.manager.system.service;

import com.itheima.heima.info.manager.system.dao.TeacherDao;
import com.itheima.heima.info.manager.system.domain.Teacher;

/*
学生业务类
与学生相关的业务
写在这个类中
 */
public class TeacherService {
    //操作dao
    private TeacherDao teacherDao= new TeacherDao();

    //判断老师是否存在
    public boolean isExist(String sid){
        Teacher[] teas = teacherDao.findAll();
        for (int i = 0; i < teas.length; i++) {
            //teas[i]
            Teacher tea = teas[i];
            if(tea!=null&& tea.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }
    //增
    public boolean addTeacher(Teacher teacher){
        return teacherDao.addTeacher(teacher);
    }

    //删
    public void deleteTeacher(String sid){
        teacherDao.deleteTeacher(sid);
    }
    //改
    public void updateTeacher(String sid,Teacher teacher){
        teacherDao.updateTeacher(sid, teacher);
    }
    //查  判断是否为null
    public Teacher[] findALl(){
        Teacher[] teas = teacherDao.findAll();
        for (int i = 0; i < teas.length; i++) {
            //有一个就不空
            if(teas[i]!=null){
                return teas;
            }
        }
        return null;
    }
}
